package org.example.viteVantDemo.exception;


import lombok.Getter;
import org.example.viteVantDemo.constants.ApiCodeEnum;
import org.example.viteVantDemo.model.ApiRes;

/*
 * 自定义业务异常
 *
 * @author tnar
 *
 */
@Getter
public class BizException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    private ApiRes apiRes;

    /**
     * 业务自定义异常
     **/
    public BizException(String msg) {
        super(msg);
        this.apiRes = ApiRes.customFail(msg);
    }

    public BizException(ApiCodeEnum apiCodeEnum, String... params) {
        super();
        apiRes = ApiRes.fail(apiCodeEnum, params);
    }

    public BizException(ApiRes apiRes) {
        super(apiRes.getMsg());
        this.apiRes = apiRes;
    }
}
